package com.proxy.scanandcheck.checker.thread;

import java.io.Serializable;

import org.apache.http.client.HttpClient;

import com.proxy.scanandcheck.checker.service.ProxyService;
import com.proxy.scanandcheck.common.valueobject.Proxy;

/**
 * Check proxy task thread.
 *
 */
public class ThreadPoolTask implements Runnable, Serializable {

	private static final long serialVersionUID = 0;

	private Proxy myProxy;
	private HttpClient httpclient;
	private String keyword;
	
	public ThreadPoolTask(HttpClient httpclient,Proxy myProxy,String keyword) {
		this.myProxy = myProxy;
		this.httpclient = httpclient;
		this.keyword = keyword;
	}

	/**
	 * Call proxy object to check if proxy is valid
	 * @return 
	 */
	public synchronized void run() {
//		System.out.println("\r\nTask start for proxy：" + httpHost);
		try {
			ProxyService proxyService = new ProxyService();
			proxyService.checkProxy(httpclient,myProxy,keyword);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		myProxy = null;
	}

	public Proxy getMyProxy() {
		return myProxy;
	}





}
